<template>
  <div class="album">
    <div class="album-item" v-for="item of albums" :key="item.id">
      <img v-lazy="item.picUrl"/>
      <span class="album-item-name">{{ item.name }}</span>
      <span class="album-item-title">
        {{item.artist.name}}
      </span>
    </div>
  </div>
</template>

<script>
import Mixins from "./Mixins";

export default {
  name: 'Album',
  mixins: [Mixins],
  data() {
    return {
      albums: [], // 专辑数据
    }
  },
  watch: {
    // 侦听路由
    '$route.query': {
      async handler() {
        // 获取专辑
        let {albums} = await this.getSongs({type: 10,pageSize:20})
        this.albums = albums
      },
      immediate: true
    }
  },
  methods: {}
}
</script>

<style lang="less" scoped>
.album {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}

.album-item {
  display: flex;
  flex-direction: column;
  margin-right: 20px;
  margin-bottom: 20px;

  img {
    width: 160px;
    height: 160px;
  }

  .album-item-name {
    font-size: 16px;
    margin: 5px 0;
  }

  .album-item-works {
    color: #909399;
    font-size: 12px;
    margin-top: 4px;
  }
}
</style>
